package mytools;

import java.util.concurrent.TimeUnit;

import gov.kqqzyyy.monkey.ydhl.R;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;
import service.TempService;
import service.YDHLService;

/**
 * Created by Monkey on 2017/11/1.
 * Service工具类
 */
public class MyServiceUtil {

    private static String baseUrl1 = MyApplication.applicationContext.getString(R.string.default_url1);
    private static String baseUrl2 = MyApplication.applicationContext.getString(R.string.default_url2);

    private static OkHttpClient client = new OkHttpClient.Builder()
            .connectTimeout(20, TimeUnit.SECONDS)
            .readTimeout(20, TimeUnit.SECONDS)
            .writeTimeout(20, TimeUnit.SECONDS)
            .build();
    private static Retrofit retrofit1 = new Retrofit.Builder()
            .baseUrl(baseUrl1)
            .client(client)
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();
    private static Retrofit retrofit2 = new Retrofit.Builder()
            .baseUrl(baseUrl2)
            .client(client)
            .addConverterFactory(ScalarsConverterFactory.create())
            .build();

    private static YDHLService ydhlService = retrofit1.create(YDHLService.class);
    private static TempService tempService = retrofit2.create(TempService.class);

    public static Call<String> getSystemTimeCall() { //获取系统时间
        return ydhlService.getSystemTime();
    }

    public static Call<String> getSBXHCall(String sbbs, String ipdz, String bzxx) {
        return ydhlService.getSBXH(sbbs, ipdz, bzxx);
    }

    public static Call<String> getLoginUserCall(String account, String password) {
        return ydhlService.getLoginUser(account, password);
    }

    public static Call<String> getSectionCall(String ygdm) {
        return ydhlService.getSectionList(ygdm);
    }

    public static Call<String> getPatientCall(String brbq) {
        return ydhlService.getPatientList(brbq);
    }

    public static Call<String> getBrbsPatientCall(String brbs) {
        return ydhlService.getPatientByBRBS(brbs);
    }


    public static Call<String> getYZJHCall(String zyh, String ksrq, String jsrq) {
        return ydhlService.getYZJHResult(zyh, ksrq, jsrq);
    }

    public static Call<String> doCheckYZJH(String ygdm, String tmbh) {
        return ydhlService.doCheckPlan(ygdm, tmbh);
    }

    public static Call<String> getJJYYCall(String ksdm) {
        return ydhlService.getJJYY(ksdm);
    }

    public static Call<String> getJYXMCall(String zyhm) {
        return ydhlService.getJYXM(zyhm);
    }

    public static Call<String> getJYJGCall(String zyhm) {
        return ydhlService.getJYJG(zyhm);
    }

    public static Call<String> getRisCall(String zyhm) {
        return ydhlService.getRis(zyhm);
    }

    public static Call<String> getUisCall(String zyhm) {
        return ydhlService.getUis(zyhm);
    }

    public static Call<String> getEcgCall(String zyhm) {
        return ydhlService.getEcg(zyhm);
    }

    public static Call<String> getEsCall(String zyhm) {
        return ydhlService.getEs(zyhm);
    }

    public static Call<String> getPisCall(String zyhm) {
        return ydhlService.getPis(zyhm);
    }
}

